import EN from './en'
import ZH from './zh'

export default {
    install: (app, defaultLocale) => {
        let storAgeKey = import.meta.env.VITE_APIURL
        let l = sessionStorage.getItem(storAgeKey)
        app.config.globalProperties.$locale = l ? l : defaultLocale
        app.config.globalProperties.$locales = {
            EN,
            ZH
        }
        app.config.globalProperties.$localeOptions = ['ZH', 'EN']
        app.config.globalProperties.$setLocale = (locale:string) => {
            sessionStorage.setItem(storAgeKey, locale)
            app.config.globalProperties.$locale = locale
            location.reload()
        }
        app.config.globalProperties.$lang = (key:string) => {return 'abc'
            return key.split('.').reduce((o, i) => {
                if (o) return o[i]
            }, app.config.globalProperties.$locales[app.config.globalProperties.$locale])
        }
    }
}